package com.zhuss.product.line;

import com.zhuss.bean.bo.product.line.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;

/**
 * @description: 线路操作的Service
 * @author: zhushanshuo
 * @create: Wed Dec 30 13:08:49 CST 2020
 **/
@Component("lineOperateService")
public class LineOperateService implements OperateService<Void, Object> {

	@Autowired
	@Qualifier("lineCreate")
	private Processor<Object, CreateLineBo> lineCreate;

	@Autowired
	@Qualifier("lineUpdate")
	private Processor<Object, UpdateLineBo> lineUpdate;

	@Autowired
	@Qualifier("lineDelete")
	private Processor<Object, DeleteLineBo> lineDelete;

	@Autowired
	@Qualifier("lineBind")
	private Processor<Object, BindLineBo> lineBind;

	@Autowired
	@Qualifier("lineStart")
	private Processor<Object, StartLineBo> lineStart;
	
	@Autowired
	@Qualifier("lineStop")
	private Processor<Object, StopLineBo> lineStop;
	
	@Autowired
	@Qualifier("lineEnable")
	private Processor<Object, EnableLineBo> lineEnable;


	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws DzcxException {

		CreateLineBo bo = (CreateLineBo) param;

		lineCreate.process(bo);

		return null;
	}

	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws DzcxException {

		UpdateLineBo bo = (UpdateLineBo) param;

		lineUpdate.process(bo);

    	return null;
    }

	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws DzcxException {

		DeleteLineBo bo = (DeleteLineBo) param;

		lineDelete.process(bo);

		return null;
	}

	public Void bind(Object param) throws DzcxException {
		BindLineBo bo = (BindLineBo) param;
		lineBind.process(bo);
		return null;
	}


	/**
	 * 启用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void start(Object param) throws DzcxException {

		StartLineBo bo = (StartLineBo) param;

		lineStart.process(bo);

		return null;
	}

	/**
	 * 停用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void stop(Object param) throws DzcxException {

		StopLineBo bo = (StopLineBo) param;
		lineStop.process(bo);

		return null;
	}
	
	/**
	 * 激活、置为模板
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void enable(Object param) throws DzcxException {
		
		EnableLineBo bo = (EnableLineBo) param;
		lineEnable.process(bo);
		
		return null;
	}

}

